<template>
  <div watcher_unit="app">
    <el-form ref="form" :model="form" label-width="108px" :rules="addForm">
      <h1>工程变更签证结算书说明</h1>
      <el-form-item label="编号" class="head" prop="project_id">
        <el-input v-model="form.project_id"></el-input>
      </el-form-item>
      <el-form-item label="工程名称" class="head" prop="project_name">
        <el-input v-model="form.project_name"></el-input>
      </el-form-item>
      <el-form-item label="变更价值" class="head" prop="change_value">
        <el-input v-model="form.change_value"></el-input>
      </el-form-item>
      <el-form-item label="监理单位" class="head" prop="watcher_unit">
        <el-input v-model="form.watcher_unit"></el-input>
      </el-form-item>
      <el-form-item label="变更签证结果" prop="application_result">
        <el-input type="textarea" v-model="form.application_result" style="width:680px"></el-input>
      </el-form-item> 
      <el-form-item label="主管领导姓名" class="head" prop="manager">
        <el-input v-model="form.manager"></el-input>
      </el-form-item>
      <el-form-item label="专工姓名" class="head" prop="special">
        <el-input v-model="form.special"></el-input>
      </el-form-item>
      <el-form-item label="编制日期" prop="date">
        <el-date-picker type="date" placeholder="选择日期" v-model="form.date" style="width: 280px;"></el-date-picker> 
      </el-form-item>
      <el-form-item>
        <el-upload
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :file-list="fileList"
          :on-error = "uploadsuccess"
          list-type="picture">
          <el-button size="small" type="primary">上传单位盖章</el-button>
          &nbsp;&nbsp;&nbsp;<span slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</span>
        </el-upload>
      </el-form-item>
      <el-form-item>
        <el-button @click.native="submit" style="width: 100px;" type="primary">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
      return {
        fileList:[],
        form: {
          project_id:'',
          project_name: '',
          change_value: '',
          watcher_unit: '',
          application_result: '',
          manager: '',
          special: '',
          date: '',
          status:0
        },
        addForm: {
          project_id: [{ required: true, message: '编号不能为空!', trigger: 'blur' },],
          project_name: [{ required: true, message: '工程名称不能为空!', trigger: 'blur' },],
          change_value: [{ required: true, message: '变更价值不能为空!', trigger: 'blur' },],
          watcher_unit: [{ required: true, message: '监理单位不能为空!', trigger: 'blur' },],
          application_result: [{ required: true, message: '变更签证结果不能为空!', trigger: 'blur' },],
          manager: [{ required: true, message: '主管领导姓名不能为空!', trigger: 'blur' },],
          special: [{ required: true, message: '专工姓名不能为空!', trigger: 'blur' },],
          date: [{ required: true, message: '编制日期不能为空!', trigger: 'blur' },],
        },
      }
    },
    methods: {
      submit(){
        //   这样做的缺陷是一次只能新建一个文件
        sessionStorage.setItem("instruction", JSON.stringify(this.form));
        this.$message({
          message: '提交成功',
          type: 'success',
          center: true
        });
      },
      // 虚伪的成功调用
      uploadsuccess(){
        console.log("success");
        this.$message({
          message: '上传成功',
          type: 'success',
          center: true
        });
      },
    }
}
</script>

<style  lang="less" scoped>
#app{
  height: auto;
}
.el-form {
  width: 800px;
  height: auto;
  margin: 0 auto;
  border: 1px dashed rgba(0, 50, 100, 0.8);
  position: relative;
  h1{
    text-align: center;
  }
  .head{
    .el-input {
      width: 280px;
    }
    display: inline-block;
  }
}
.el-upload--text{
  width: 419px;
  height: 36px;
}
</style>